#ifndef ANY_H
#define ANY_H
#include "Logger.hpp"
#include <memory>
class Any
{
public:
	Any() = default;
	~Any() = default;

	Any(const Any&) = delete;
	Any& operator=(const Any&) = delete;
	Any(Any&&) = default;
	Any& operator=(Any&&) = default;

	template<typename T>
	Any(T data):base_(std::make_unique<Derive<T>>(data)){}

	//get data
	template<typename T>
	T cast_()
	{
		Derive<T> * dp = dynamic_cast<Derive<T>*>(base_.get());
		if (dp == nullptr)
		{
			throw "Type mismatch!";
			LOG_ERROR("TYPE MISMATCH!\n");
		}
		return dp->date_;
	}
private:
	class Base {
	public:
		virtual ~Base() = default;
	};

	template<typename T>
	class Derive :public Base {
	public:
		Derive(T date) :date_(date) {};

		T date_;
	};
private:
	std::unique_ptr<Base> base_;
};

#endif